# config.py
# from src.core.config_loader import load_config
from src.core.config_loader import load_config
import os
from src.core import str_utils as stru
from src.core import json_loader

# 加载环境变量
load_config()


class Config:
    # 服务端口配置
    SERVER_PORT=stru.convert_to_int(os.getenv('SERVER_PORT'), 8080)
    SERVER_HOST=os.getenv('SERVER_HOST')
    #数据库连接信息
    DB_HOST = os.getenv('DB_HOST')
    DB_PORT = os.getenv('DB_PORT')
    DB_SID = os.getenv('DB_SID')
    DB_USERNAME = os.getenv('DB_USERNAME')
    DB_PASSWORD = os.getenv('DB_PASSWORD')
    DB_TYPE = os.getenv('DB_TYPE')

    # JWT 配置
    SECRET_KEY = os.getenv('SECRET_KEY')
    ALGORITHM = os.getenv('ALGORITHM')
    ACCESS_TOKEN_EXPIRE_MINUTES = stru.convert_to_int(os.getenv('ACCESS_TOKEN_EXPIRE_MINUTES'), 30)
    REFRESH_TOKEN_EXPIRE_MINUTES = stru.convert_to_int(os.getenv('REFRESH_TOKEN_EXPIRE_MINUTES'), 10080)

    # STATIC_URL
    STATIC_URL = os.getenv('STATIC_URL')

    # LOGGER
    LOG_DIR = os.getenv('LOG_DIR')
    DEBUG = stru.convert_bool(os.getenv('DEBUG'))

    # 加密配置
    CRYPT_KEY = os.getenv('CRYPT_KEY')
    CRYPT_ENABLED = os.getenv('CRYPT_ENABLED')

    # Message 配置
    MESSAGE_DEFAULT_LANGUAGE = os.getenv('MESSAGE_DEFAULT_LANGUAGE')
    # 读取环境变量时给默认值，避免空值导致列表异常
    MESSAGE_LANGUAGES = os.getenv('MESSAGE_LANGUAGES', 'zh,en,fr,zh-TW').split(',')
    MESSAGE_FILE_PATH=os.getenv('MESSAGE_FILE_PATH', '')
    MESSAGE_CONTENT_JSON=json_loader.load_json(MESSAGE_FILE_PATH)


    # 其他配置项...
